package com.example.tool.activtiy;

import android.support.v7.widget.CardView;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.tool.R;
import com.example.tool.activtiy.base.BaseActivity;
import com.example.tool.mvp.CommonPresent;
import com.example.tool.util.LogUitl;

import butterknife.BindView;

/**
 * Created Date 2019/8/30
 *
 * @author liangkun
 * description：动画的案例
 */
public class TweenAnimActivity extends BaseActivity<CommonPresent> {
    @BindView(R.id.card_home_item)
    protected CardView cardOne;
    @BindView(R.id.card_home_two)
    protected CardView cardTwo;
    @BindView(R.id.card_home_three)
    protected CardView cardThree;
    @BindView(R.id.card_home_four)
    protected CardView cardFour;
    @BindView(R.id.card_home_five)
    protected CardView cardFive;
    @BindView(R.id.iv_anim)
    protected ImageView iv_anim;

    @BindView(R.id.llMain)
    protected LinearLayout llMain;
    @BindView(R.id.tv_title)
    protected TextView tvTitle;

    @Override
    protected int getLayoutId() {
        return R.layout.tween_anim;
    }

    @Override
    protected void initView() {
        tvTitle.setText("补间动画");
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void initEvent() {
        cardOne.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Animation animation = AnimationUtils.loadAnimation(TweenAnimActivity.this, R.anim.rotate);
                iv_anim.startAnimation(animation);
            }
        });
        cardTwo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Animation animation = AnimationUtils.loadAnimation(TweenAnimActivity.this, R.anim.translate);
                iv_anim.startAnimation(animation);


            }
        });
        cardThree.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Animation animation = AnimationUtils.loadAnimation(TweenAnimActivity.this, R.anim.scale);
                iv_anim.startAnimation(animation);
                animation.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {
                        LogUitl.getInstance().w("onAnimationStart");
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        LogUitl.getInstance().w("onAnimationEnd");
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                        LogUitl.getInstance().w("onAnimationRepeat");
                    }
                });

//                ViewCompat.animate(cardThree).scaleX(1.5f).scaleY(1.5f).setDuration(1500).
//                        setInterpolator(new AccelerateInterpolator()).start();

            }
        });
        cardFour.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Animation animation = AnimationUtils.loadAnimation(TweenAnimActivity.this, R.anim.alpha);
                iv_anim.startAnimation(animation);

            }
        });
        cardFive.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Animation animation = AnimationUtils.loadAnimation(TweenAnimActivity.this, R.anim.set);
                iv_anim.startAnimation(animation);

            }
        });


    }

    @Override
    protected CommonPresent createPresenter() {
        return null;
    }

}
